<?php
if($action=='del')
  {
 $ary=$HTTP_COOKIE_VARS["Cart"];
 $ary1=explode('##', $ary);
 //echo $ary1[1];
 $n=count($ary1);
 //echo 'n= '.$n;
 $k=1;
 while($k<=$n-1)
 {
 if($k==$id) 
 {
 $k++; 
 continue;
 }
 //echo $ary1[$k].'<BR>';
 $newcart=$newcart.'##'.$ary1[$k];
  $k++;
 }
 setcookie("Cart",$newcart,time()+604800);
 //echo '***'.$newcart;?>
 <script type="text/javascript">
 window.location.assign('cart_view.php?site_id=<?php echo $_SESSION['SITE_ID'];?>');
 </script>
 <?php 
  } 
  ?>
<style type="text/css">
<!--
.style10 {font-family: Verdana; font-weight: bold; font-size: 10px; }
.style12 {font-family: Verdana; font-weight: bold; font-size: 14px; }
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
.style20 {font-family: Verdana; font-weight: bold; font-size: 12; color: #FF0000; }
.style22 {font-family: Verdana; font-weight: bold; font-size: 11px; }
-->
</style>
<table width="432" border="0" align="center">
  <tr>
    <td colspan="4"><div align="center"><span class="style12">CART</span></div></td>
  </tr>
  <tr class="style10">
    <td width="148"><span class="style10">ITEM</span></td>
    <td width="131"><span class="style10">QTY</span></td>
    <td width="139"><span class="style10">Price</span></td>
    <td width="139">&nbsp;</td>
  </tr>
  <?php
//  include_once('ClsSebent/config.php');  
$cart=$HTTP_COOKIE_VARS["Cart"];
//echo $cart;
$cart_array=explode('##', $cart);
$num=count($cart_array);
$i=1;
while($i<=$num-1){
$line_array=explode(',',substr($cart_array[$i],1,strlen($cart_array[$i])));
  ?>
  <tr class="style10">
    <td><?php echo $line_array[2];?></td>
    <td><?php echo $line_array[3];?></td>
    <td><span class="style10">$<?php $sum=$sum+$line_array[9]; echo $line_array[9];?></span></td>
    <td><a href="cart_view.php?site_id=<?php echo $_SESSION['SITE_ID'];?>&id=<?php echo $i;?>&action=del">Remove Item</a></td>
  </tr>
  <?php $i++;}?>
  <tr>
    <td><span class="style20">Total</span></td>
    <td>&nbsp;</td>
    <td><span class="style20"><hr align="left" width="100%" color="#FFFFFF"/>$<?php echo $sum;?><hr align="left" width="100%" color="#FFFFFF"/></span></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="47"><!--<input name="action" type="submit" value="Save Cart" onclick="javascript: window.open('cart_save.php?site_id=<?php //echo $_SESSION['SITE_ID'];?>');"></td>-->
      <a href="reg_buyer.php?site_id=<?php echo $_SESSION['SITE_ID'];?>" class="style22">Buyer Signup</a> 
    <td><input name="action" type="reset" value="Check Out" onclick="javascript: chkbuyer();"></td>
    <td><input type="button" value="Close" onclick="javascript: window.close('cart_view.php');"></td>
    <td><a href="buyer_login.php?site_id=<?php echo $_SESSION['SITE_ID'];?>" class="style22">Buyer Login<br />
      </a><a href="buyer_logout.php?site_id=<?php echo $_SESSION['SITE_ID'];?>" class="style22">Buyer Logout</a><a href="buyer_login.php?site_id=<?php echo $_SESSION['SITE_ID'];?>" class="style22"><br />
    </a></td>
  </tr>
</table>
<script type="text/javascript">
function chkbuyer()
{
<?php 
$buyer_cook=$HTTP_COOKIE_VARS['buyer'];
if($buyer_cook!='')
{?>
window.open('payment.php?site_id=<?php echo $_SESSION['SITE_ID'];?>');
<?php
} else{
?>
	alert("If you are a registered buyer,Please Log In. Otherwise Sign up to proceed shopping.");
	<?php }?>
}
</script>